from django.urls import path, include, re_path
from django.contrib import admin
from rest_framework import routers
from django.views.static import serve
from django.conf import settings
from django.conf.urls.static import static
from qianyin.views import *
import time
from rest_framework.documentation import include_docs_urls
def newDate(request):
    return  HttpResponse(time.strftime("%Y-%m-%d %H:%M", time.localtime()))

# Routers provide an easy way of automatically determining the URL conf.
# router = routers.DefaultRouter()
# router.register(r'home/carousel', MallCarouselViewSet)
# router.register(r'home/config', MallIndexConfigViewSet)
# router.register(r'goods_category', MallGoodsCategoryViewSet)
# router.register(r'goods_cart', MallCartViewSet)
# router.register(r'user/info', MallUserViewSet)
# router.register(r'user/address', UserAddressViewSet)
# router.register(r'user/token', UserTokenViewSet)
# router.register(r'goods/info', MallGoodsInfoViewSet)
# router.register(r'goods/comment', MallCommentViewSet)
# router.register(r'order/info_', MallOrderViewSet)
# router.register(r'order/item_', OrderItemViewSet)
# router.register(r'order/address_', OrderAddressViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
    path('admin/', admin.site.urls),
    path('chart/pie', chartpie),
    path('chart/line', chartline),
    path('chart/wordcloud', chartwordcloud),
    path('intdoc/', include_docs_urls(title='Interface documentation')),
    # path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    path('goods-api/home/carousel/', MallCarouselViewSet.as_view({'get': 'defined'}), name='Carouse'),
    path('goods-api/home/config/', MallIndexConfigViewSet.as_view({'get': 'defined'}), name='config'),
    path('goods-api/goods/info/<name>', MallGoodsInfoViewSet.as_view({'get': 'defined'}), name='goodsconfig'),
    path('goods-api/goods_category/<num>', MallGoodsCategoryViewSet.as_view({'get': 'defined'}), name='goods_category'),
    path(r'goods-api/date/', newDate),
    path(r'goods-api/userinfo/id=<id>&pwd=<pwd>', UserinfoViewSet.as_view({'post': 'getUser'}), name='userinfo'),
    path(r'goods-api/userzhuce/id=<id>&pwd=<pwd>&nick=<nick>', UserzhuceViewSet.as_view({'post': 'zhuceUser'}), name='userzhuce'),
    re_path(r'^goods-api/home/info/(?P<type>[0-9])&?(?P<third>[0-9])$', HomeInfoViewSet.as_view({'get': 'defined'}), name='homeinfo'),
    re_path(r'^goods-api/goods/infoo/(?P<id>[0-9]+)$', DetailViewSet.as_view({'get': 'defined'}), name='Detail'),
    path(r'goods-api/order/info/<goodsid>&<nick>&<num>&<paytpye>', OrderinfoViewSet.as_view({'post': 'defined'}), name='Orderinfo'),
    path(r'goods-api/cart/<goodsid>&<nick>&<num>', CartViewSet.as_view({'post': 'defined'}), name='cart'),
    path(r'goods-api/getcart/<nick>', getCartViewSet.as_view({'get': 'defined'}), name='getcart'),
    path(r'goods-api/goodscart/', goodsCartViewSet.as_view({'put': 'defined'}), name='goodsCart'),
    path(r'goods-api/goodsorder/', goodsOrderViewSet.as_view({'post': 'postorder'}), name='goodsOrder'),
    re_path(r'^goods-api/goodsorder/(?P<nick>.*?)$', goodsOrderViewSet.as_view({'get': 'getorder'}), name='goodsOrder'),
]